﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>出退勤设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">基础数据设置</a><span lay-separator="">/</span>
            <a><cite>出退勤设置</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="weadmin-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="StartSignInTime" class="layui-form-label" style="width:200px">
                    <span class="we-red"></span>开课前允许签到时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="StartSignInTime" name="StartSignInTime" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" style="text-align:left">
                    <span class="we-red"></span>(分钟)
                </label>
            </div>

            <div class="layui-form-item">
                <label for="SignInTime" class="layui-form-label" style="width:200px">
                    <span class="we-red"></span>允许迟到时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="SignInTime" name="SignInTime" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" style="text-align:left">
                    <span class="we-red"></span>(分钟)
                </label>
            </div>
            <div class="layui-form-item">
                <label for="SignOutTime" class="layui-form-label" style="width:200px">
                    <span class="we-red"></span>允许早退时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="SignOutTime" name="SignOutTime" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" style="text-align:left">
                    <span class="we-red"></span>(分钟)
                </label>
            </div>

            <div class="layui-form-item">
                <label for="EndSignOutTime" class="layui-form-label" style="width:200px">
                    <span class="we-red"></span>结束后允许签退时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="EndSignOutTime" name="EndSignOutTime" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" style="text-align:left">
                    <span class="we-red"></span>(分钟)
                </label>
            </div>


            <div class="layui-form-item">
                <label for="RandomNum" class="layui-form-label" style="width:200px">
                    <span class="we-red"></span>随机考试人数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="RandomNum" name="RandomNum" autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label" style="text-align:left">
                    <span class="we-red" ></span>%(百分比)
                </label>
            </div>

            <div class="layui-form-item">

                <label for="RandomNum" class="layui-form-label" style="width:200px">
                </label>

                <button class="layui-btn" lay-filter="edit" lay-submit="" style="width:190px">确定</button>
            </div>

        </form>

    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../../static/js/common.js" charset="utf-8"></script>
    <script type="text/javascript">
        layui.use(['form', 'layer', 'jquery'], function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer;
            $.support.cors = true;
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            $.ajax({
                url: ApiUrl + "AttendanceSet/GetAttendanceSet",
                type: 'get',
                dataType: 'json',
                //data: obj,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
                success: function (data) {
                    if (data.StatusCode == 200) {
                        $("#StartSignInTime").val(data.Data[0].StartSignInTime);
                        $("#SignInTime").val(data.Data[0].SignInTime);
                        $("#SignOutTime").val(data.Data[0].SignOutTime);
                        $("#EndSignOutTime").val(data.Data[0].EndSignOutTime);
                        $("#RandomNum").val(data.Data[0].RandomNum);
                    }
                    else if (data.StatusCode == 403) {
                        layer.alert(data.Info, function () {
                            top.location.href = "http://" + top.location.host + "/login.html";
                        })
                    }
                    else {
                        layer.msg(data.Info);
                    }
                }
            });



            //监听提交
            form.on('submit(edit)', function (data) {
                var StartSignInTime = $("#StartSignInTime").val().trim();
                if (StartSignInTime == "") {
                    layer.msg("开课前允许签到时间！");
                    return false;
                }
                var SignInTime = $("#SignInTime").val().trim();
                if (SignInTime == "") {
                    layer.msg("请输入允许迟到时间！");
                    return false;
                }
                var SignOutTime = $("#SignOutTime").val().trim();
                if (SignOutTime == "") {
                    layer.msg("请输入允许早退时间！");
                    return false;
                }
                var EndSignOutTime = $("#EndSignOutTime").val().trim();
                if (EndSignOutTime == "") {
                    layer.msg("结束后允许签退时间！");
                    return false;
                }
                var RandomNum = $("#RandomNum").val().trim();
                if (RandomNum == "") {
                    layer.msg("请输入随机考试人数！");
                    return false;
                }
                var obj = { AutoID:1, StartSignInTime: StartSignInTime, SignInTime: SignInTime, SignOutTime: SignOutTime, EndSignOutTime: EndSignOutTime, RandomNum: RandomNum};
                console.log(JSON.stringify(obj));
                $.ajax({
                    url: ApiUrl + "AttendanceSet/Edit",
                    type: 'post',
                    dataType: 'json',
                    data: obj,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            layer.alert("修改成功", { icon: 6 }, function (index) {
                                layer.close(index);
                            })
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });




                return false;
            });
        });
    </script>
</body>

</html>